package com.fr.cell.core;

import com.fr.data.core.DataUtils;
import com.fr.data.util.function.DataFunction;
import java.awt.Component;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JComboBox;
import javax.swing.JList;

public class FunctionComboBox extends JComboBox
{
  DefaultListCellRenderer functionCellRenderer = new DefaultListCellRenderer(this)
  {
    private final FunctionComboBox this$0;

    public Component getListCellRendererComponent(, Object paramObject, int paramInt, boolean paramBoolean1, boolean paramBoolean2)
    {
      super.getListCellRendererComponent(paramJList, paramObject, paramInt, paramBoolean1, paramBoolean2);
      if (paramObject instanceof DataFunction)
      {
        DataFunction localDataFunction = (DataFunction)paramObject;
        setText(DataUtils.getFunctionDisplayName(localDataFunction));
      }
      return this;
    }
  };

  public FunctionComboBox(DataFunction[] paramArrayOfDataFunction)
  {
    setModel(new DefaultComboBoxModel(paramArrayOfDataFunction));
    setRenderer(this.functionCellRenderer);
  }

  public DataFunction getFunction()
  {
    return ((DataFunction)getSelectedItem());
  }

  public void setFunction(DataFunction paramDataFunction)
  {
    if (paramDataFunction == null)
      return;
    DefaultComboBoxModel localDefaultComboBoxModel = (DefaultComboBoxModel)getModel();
    for (int i = 0; i < localDefaultComboBoxModel.getSize(); ++i)
    {
      DataFunction localDataFunction = (DataFunction)localDefaultComboBoxModel.getElementAt(i);
      if (localDataFunction == null)
        break label64:
      if (paramDataFunction.getClass().equals(localDataFunction.getClass()))
      {
        setSelectedIndex(i);
        return;
      }
    }
    label64:
  }
}